<template>
    <div class="makerList">
        <div class="makerList_top">
			<div class="into_index">首页<i class="el-icon-close"></i></div>
			<div class="current">提现记录<i class="el-icon-close"></i></div>
		</div>
        <div class="makerList_bottom">
            <div class="new">
               <div class="newCard">
                   提现状态 
					<el-select style="margin-left:10px" @change="selectFn" v-model="value" placeholder="请选择">
                        <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.name"
                        :value="item.value">
                        </el-option>
                    </el-select>
				</div>
            </div>
            
            <div class="makerList_table">
                <div class="makerList_bottom_table">
					<table>
						<tr>
							<th></th>
							<th>序号</th>
							<th>提现时间</th>
							<th>提现金额</th>
							<th>状态</th>
							<!-- <th>操作</th> -->
						</tr>
						<tr v-for="(v,i) in tableList" :key="i">
							<td>
								<font class="checkbox" :class="{'check_active' : checkBoxAll.includes(i)}" @click="handlerCheckbox(i)"><i class="el-icon-check"></i></font>
							</td>
							<td>{{v.id}}</td>
							<td>{{$moment(v.create_time*1000).format('yyyy-MM-DD')}}</td>
							<td>{{v.amount}}</td>
							<td>{{v.status==0?'未批准':v.status==1?'已通过':v.status==2?'被拒绝':v.status==3?'已结算':v.status==4?'个人取消':'待审核'}}</td>
							<!-- <td>
								<button class="editor" @click="toDel(v.id)">删除</button>
							</td> -->
						</tr>
						<tr v-if="tableList.length == 0"><td class="table_title" colspan="12">当前数据空空如也</td></tr>
					</table>
				</div>
				<div class="makerList_bottom_page">
				<div class="makerList_bottom_page_left">
					<div class="makerList_bottom_page_left_checkAll" @click="handerCheckAll">
						<font class="checkbox" :class="{'check_active' : checkAll}"><i class="el-icon-check"></i></font>
					</div>全选
					<!-- <button class="busineList_bottom_page_left_btn" @click="selectDel">删除</button> -->
					</div>
					<div class="makerList_bottom_page_right">
						<el-pagination
							@size-change="handleSizeChange"
							@current-change="handleCurrentChange"
							:current-page="page"
							:page-sizes="[10, 20, 30, 40]"
							:page-size="pageSize"
							layout="total, sizes, prev, pager, next, jumper"
							:total="total"
							background>
						</el-pagination>
					</div>
				</div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            tableList:[],
            input:'',
			checkAll:false,
			page:1,
			pageSize:10,
			total:0,
            checkBoxAll:[],				// 选中的数据
			shelvesAlls:[],
			balanceInfo:{}, //余额信息
            options:[{
                name:'待审核',
                value:1
            },{
                name:'被拒绝',
                value:2
            },{
                name:'已结算',
                value:3
            },],
			value:'',
        }
    },
	mounted(){
        this.getRecordsList()
	},
    methods: {
        // 获取提现记录
        getRecordsList(){
            this.$api.getRecordsList({status:this.value,level:1}).then(res=>{
                console.log(res)
                if(res.code==1){
                    this.tableList = res.data.list?res.data.list:[]
                }
            })
        },
		// 选择状态
		selectFn(e){
			this.getRecordsList()
		},

         // 多选
			handlerCheckbox(i){
                console.log(i);
				let arr = this.checkBoxAll;
				if(arr.includes(i)){
					let index = arr.indexOf(i);
					if(index > -1){
						arr.splice(index,1);
						if(this.checkBoxAll.length !== this.tableList.length) {
							this.checkAll = false;
						}
					}
				}else {
					this.checkBoxAll.push(i);
					if(this.checkBoxAll.length == this.tableList.length) {
						this.checkAll = true;
					}
				};
				this.shelvesAlls.push(this.tableList[i].product_id);
				console.log(this.shelvesAlls);
			},
            // 全选与全不选
			handerCheckAll(){
				this.checkAll = !this.checkAll;
				let arr = this.tableList.length;
				this.checkBoxAll = [];
				if(this.checkAll){
					for(let i=0;i<arr;i++){
						this.checkBoxAll.push(i);
					}
				}else {
					this.checkBoxAll = [];
				}
				// 去重
				let res = this.checkBoxAll;
				for(let i=0;i<res.length;i++){
					for(let j=i+1;j<res.length;j++) {
						if(res[i] == res[j]) {
							res.splice(j,1);
							j--;
						}
					}
				};
				this.checkBoxAll.map(v => {
					return this.shelvesAlls.push(this.tableList[v].store_id.toString());;
				})
				
				console.log(this.shelvesAlls);
			},

        // 搜索
        handerSeach(){},

        handleChange1(){},
        handleChange2(){},

        //分页
			handleSizeChange(val) {
				this.pageSize = val;
				console.log(val);
				this.getRecordsList()
			},
			handleCurrentChange(val) {
			    this.page = val;
				console.log(val);
				this.getRecordsList()
			},
    },
}
</script>

<style lang="less" scoped>
    @import 'records.less';
</style>